#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
ll f[1000] = {0, 1};
ll k;

int main() {
    for (int i = 2; i <= 60; i++)f[i] = (f[i - 1] + f[i - 2]) % 10;
    while (cin >> k) {
        k %= 60;
        cout << f[k] << endl;
    }
    return 0;
}